import request from '@/axios'
import type { CurdData } from './types'

export const getFieldEnumApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/admin/customer/fieldEnum', params })
}

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/customer', params })
}
export const getListForDiscountApi = (params: any) => {
  return request.get({ url: '/admin/customer/discountList', params })
}

export const getPublicListApi = (params: any) => {
  return request.get({ url: '/admin/customer/public', params })
}

export const saveDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/customer', data })
  } else {
    return request.post({ url: '/admin/customer', data })
  }
}

export const getDetApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/customer/' + id, params: { id } })
}

export const delListApi = (ids: string): Promise<IResponse> => {
  return request.delete({ url: '/admin/customer', data: { ids } })
}

export const fishingtApi = (data: Partial<any>): Promise<IResponse> => {
  return request.put({ url: '/admin/customer/public/fishing', data })
}

export const allocationApi = (data: Partial<any>): Promise<IResponse> => {
  return request.put({ url: '/admin/customer/public/allocation', data })
}

export const returnPublicApi = (data: Partial<any>): Promise<IResponse> => {
  return request.put({ url: '/admin/customer/returnPublic', data })
}

export const getSelectApi = (params?: any) => {
  return request.get({ url: '/admin/customer/select', params })
}

export const getOperationLogApi = (params: any) => {
  return request.get({ url: '/admin/customer/operationLog', params })
}

export const filingCabinetApi = (params: any) => {
  return request.get({ url: '/admin/filingcabinet', params })
}

export const customerApprovalRecordsApi = (params: any) => {
  return request.get({ url: '/admin/customer/approvalRecords', params })
}

/* 更新客户角色 */
export const updateRoleApi = (data: Partial<any>): Promise<IResponse> => {
  return request.put({ url: '/admin/customer/role', data })
}
